﻿using System;
using System.Collections.Generic;
using System.Text;

//http://www.51testing.com/ddimg/uploadsoft/20090113/OATSEN.pdf

namespace QAToolsAddin {
    internal class Experiment {
        private int[,] _matrix;
        public int[] NbLevels { get; private set; }
        public int NbFactor { get; private set; }
        public int NbExperiment { get; private set; }

        private Experiment(int[,] matrix, int[] levels) {
            _matrix = matrix;
            NbExperiment = _matrix.GetLength(0);
            NbFactor = _matrix.GetLength(1);
            NbLevels = levels;
        }

        public object[,] GetArray(List<string[]> parameters) {
            int nbNewCol = 0;
            foreach (var param in parameters) {
                if (param != null && param.Length > 0)
                    nbNewCol++;
            }
            var array = ExcelArray<object>.Create(NbExperiment, nbNewCol);
            for (int c = 0, ci = 0; c < parameters.Count; c++) {
                var values = parameters[c];
                if (values == null || values.Length == 0) continue;
                ci++;
                for (int r = 0; r < NbExperiment; r++) {
                    var index = _matrix[r, c];
                    if (index < values.Length)
                        array[r + 1, ci] = values[index];
                }
            }
            return array;
        }


        #region Taguchi Designs

        internal static Experiment Taguchi_L4_3_2 {
            get {
                return new Experiment(new int[,]{
                    {0,0,0},
                    {0,1,1},
                    {1,0,1},
                    {1,1,0}
                }, new int[] { 2, 2, 2 });
            }
        }

        internal static Experiment Taguchi_L8_7_2 {
            get {
                return new Experiment(new int[,]{
                    {0,0,0,0,0,0,0},
                    {0,0,0,1,1,1,1},
                    {0,1,1,0,0,1,1},
                    {0,1,1,1,1,0,0},
                    {1,0,1,0,1,0,1},
                    {1,0,1,1,0,1,0},
                    {1,1,0,0,1,1,0},
                    {1,1,0,1,0,0,1}
                }, new int[] { 2, 2, 2, 2, 2, 2, 2 });
            }
        }

        internal static Experiment Taguchi_L12_11_2 {
            get {
                return new Experiment(new int[,]{
                    {0,0,0,0,0,0,0,0,0,0,0},
                    {0,0,0,0,0,1,1,1,1,1,1},
                    {0,0,1,1,1,0,0,0,1,1,1},
                    {0,1,0,1,1,0,1,1,0,0,1},
                    {0,1,1,0,1,1,0,1,0,1,0},
                    {0,1,1,1,0,1,1,0,1,0,0},
                    {1,0,1,1,0,0,1,1,0,1,0},
                    {1,0,1,0,1,1,1,0,0,0,1},
                    {1,0,0,1,1,1,0,1,1,0,0},
                    {1,1,1,0,0,0,0,1,1,0,1},
                    {1,1,0,1,0,1,0,0,0,1,1},
                    {1,1,0,0,1,0,1,0,1,1,0}
                }, new int[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 });
            }
        }

        internal static Experiment Taguchi_L16_15_2 {
            get {
                return new Experiment(new int[,]{
                    {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                    {0,0,0,0,0,0,0,1,1,1,1,1,1,1,1},
                    {0,0,0,1,1,1,1,0,0,0,0,1,1,1,1},
                    {0,0,0,1,1,1,1,1,1,1,1,0,0,0,0},
                    {0,1,1,0,0,1,1,0,0,1,1,0,0,1,1},
                    {0,1,1,0,0,1,1,1,1,0,0,1,1,0,0},
                    {0,1,1,1,1,0,0,0,0,1,1,1,1,0,0},
                    {0,1,1,1,1,0,0,1,1,0,0,0,0,1,1},
                    {1,0,1,0,1,0,1,0,1,0,1,0,1,0,1},
                    {1,0,1,0,1,0,1,1,0,1,0,1,0,1,0},
                    {1,0,1,1,0,1,0,0,1,0,1,1,0,1,0},
                    {1,0,1,1,0,1,0,1,0,1,0,0,1,0,1},
                    {1,1,0,0,1,1,0,0,1,1,0,0,1,1,0},
                    {1,1,0,0,1,1,0,1,0,0,1,1,0,0,1},
                    {1,1,0,1,0,0,1,0,1,1,0,1,0,0,1},
                    {1,1,0,1,0,0,1,1,0,0,1,0,1,1,0}
                }, new int[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 });
            }
        }

        internal static Experiment Taguchi_L32_31_2 {
            get {
                return new Experiment(new int[,]{
                    {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
                    {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
                    {0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1},
                    {0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0},
                    {0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1},
                    {0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0},
                    {0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0},
                    {0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1},
                    {0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1},
                    {0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0},
                    {0,1,1,0,0,1,1,1,1,0,0,1,1,0,0,0,0,1,1,0,0,1,1,1,1,0,0,1,1,0,0},
                    {0,1,1,0,0,1,1,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,0,0,1,1,0,0,1,1},
                    {0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0},
                    {0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1},
                    {0,1,1,1,1,0,0,1,1,0,0,0,0,1,1,0,0,1,1,1,1,0,0,1,1,0,0,0,0,1,1},
                    {0,1,1,1,1,0,0,1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1,0,0,1,1,1,1,0,0},
                    {1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1},
                    {1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0},
                    {1,0,1,0,1,0,1,1,0,1,0,1,0,1,0,0,1,0,1,0,1,0,1,1,0,1,0,1,0,1,0},
                    {1,0,1,0,1,0,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0,1,0,1,0,1,0,1},
                    {1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0},
                    {1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1},
                    {1,0,1,1,0,1,0,1,0,1,0,0,1,0,1,0,1,0,1,1,0,1,0,1,0,1,0,0,1,0,1},
                    {1,0,1,1,0,1,0,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,0,1,0,1,1,0,1,0},
                    {1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0},
                    {1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1},
                    {1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1},
                    {1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0},
                    {1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1},
                    {1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0},
                    {1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0},
                    {1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1}
                }, new int[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 });
            }
        }

        internal static Experiment Taguchi_L9_4_3 {
            get {
                return new Experiment(new int[,]{
                    {0,0,0,0},
                    {0,1,1,1},
                    {0,2,2,2},
                    {1,0,1,2},
                    {1,1,2,0},
                    {1,2,0,1},
                    {2,0,2,1},
                    {2,1,0,2},
                    {2,2,1,0}
                }, new int[] { 3, 3, 3, 3 });
            }
        }

        internal static Experiment Taguchi_L27_13_3 {
            get {
                return new Experiment(new int[,]{
                    {0,0,0,0,0,0,0,0,0,0,0,0,0},
                    {0,0,0,0,1,1,1,1,1,1,1,1,1},
                    {0,0,0,0,2,2,2,2,2,2,2,2,2},
                    {0,1,1,1,0,0,0,1,1,1,2,2,2},
                    {0,1,1,1,1,1,1,2,2,2,0,0,0},
                    {0,1,1,1,2,2,2,0,0,0,1,1,1},
                    {0,2,2,2,0,0,0,2,2,2,1,1,1},
                    {0,2,2,2,1,1,1,0,0,0,2,2,2},
                    {0,2,2,2,2,2,2,1,1,1,0,0,0},
                    {1,0,1,2,0,1,2,0,1,2,0,1,2},
                    {1,0,1,2,1,2,0,1,2,0,1,2,0},
                    {1,0,1,2,2,0,1,2,0,1,2,0,1},
                    {1,1,2,0,0,1,2,1,2,0,2,0,1},
                    {1,1,2,0,1,2,0,2,0,1,0,1,2},
                    {1,1,2,0,2,0,1,0,1,2,1,2,0},
                    {1,2,0,1,0,1,2,2,0,1,1,2,0},
                    {1,2,0,1,1,2,0,0,1,2,2,0,1},
                    {1,2,0,1,2,0,1,1,2,0,0,1,2},
                    {2,0,2,1,0,2,1,0,2,1,0,2,1},
                    {2,0,2,1,1,0,2,1,0,2,1,0,2},
                    {2,0,2,1,2,1,0,2,1,0,2,1,0},
                    {2,1,0,2,0,2,1,1,0,2,2,1,0},
                    {2,1,0,2,1,0,2,2,1,0,0,2,1},
                    {2,1,0,2,2,1,0,0,2,1,1,0,2},
                    {2,2,1,0,0,2,1,2,1,0,1,0,2},
                    {2,2,1,0,1,0,2,0,2,1,2,1,0},
                    {2,2,1,0,2,1,0,1,0,2,0,2,1}
                }, new int[] { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 });
            }
        }

        internal static Experiment Taguchi_L36_13_3 {
            get {
                return new Experiment(new int[,]{
                    {0,0,0,0,0,0,0,0,0,0,0,0,0},
                    {1,1,1,1,1,1,1,1,1,1,1,1,0},
                    {2,2,2,2,2,2,2,2,2,2,2,2,0},
                    {0,0,0,0,1,1,1,1,2,2,2,2,0},
                    {1,1,1,1,2,2,2,2,0,0,0,0,0},
                    {2,2,2,2,0,0,0,0,1,1,1,1,0},
                    {0,0,1,2,0,1,2,2,0,1,1,2,0},
                    {1,1,2,0,1,2,0,0,1,2,2,0,0},
                    {2,2,0,1,2,0,1,1,2,0,0,1,0},
                    {0,0,2,1,0,2,1,2,1,0,2,1,0},
                    {1,1,0,2,1,0,2,0,2,1,0,2,0},
                    {2,2,1,0,2,1,0,1,0,2,1,0,0},
                    {0,1,2,0,2,1,0,2,2,1,0,1,1},
                    {1,2,0,1,0,2,1,0,0,2,1,2,1},
                    {2,0,1,2,1,0,2,1,1,0,2,0,1},
                    {0,1,2,1,0,0,2,1,2,2,1,0,1},
                    {1,2,0,2,1,1,0,2,0,0,2,1,1},
                    {2,0,1,0,2,2,1,0,1,1,0,2,1},
                    {0,1,0,2,2,2,0,1,1,0,1,2,1},
                    {1,2,1,0,0,0,1,2,2,1,2,0,1},
                    {2,0,2,1,1,1,2,0,0,2,0,1,1},
                    {0,1,1,2,2,0,1,0,0,2,2,1,1},
                    {1,2,2,0,0,1,2,1,1,0,0,2,1},
                    {2,0,0,1,1,2,0,2,2,1,1,0,1},
                    {0,2,1,0,1,2,2,0,2,0,1,1,2},
                    {1,0,2,1,2,0,0,1,0,1,2,2,2},
                    {2,1,0,2,0,1,1,2,1,2,0,0,2},
                    {0,2,1,1,1,0,0,2,1,2,0,2,2},
                    {1,0,2,2,2,1,1,0,2,0,1,0,2},
                    {2,1,0,0,0,2,2,1,0,1,2,1,2},
                    {0,2,2,2,1,2,1,1,0,1,0,0,2},
                    {1,0,0,0,2,0,2,2,1,2,1,1,2},
                    {2,1,1,1,0,1,0,0,2,0,2,2,2},
                    {0,2,0,1,2,1,2,0,1,1,2,0,2},
                    {1,0,1,2,0,2,0,1,2,2,0,1,2},
                    {2,1,2,0,1,0,1,2,0,0,1,2,2}
                }, new int[] { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 });
            }
        }

        internal static Experiment Taguchi_L16_5_4 {
            get {
                return new Experiment(new int[,]{
                    {0,0,0,0,0},
                    {0,1,1,1,1},
                    {0,2,2,2,2},
                    {0,3,3,3,3},
                    {1,0,1,2,3},
                    {1,1,0,3,2},
                    {1,2,3,0,1},
                    {1,3,2,1,0},
                    {2,0,2,3,1},
                    {2,1,3,2,0},
                    {2,2,0,1,3},
                    {2,3,1,0,2},
                    {3,0,3,1,2},
                    {3,1,2,0,3},
                    {3,2,1,3,0},
                    {3,3,0,2,1}
                }, new int[] { 4, 4, 4, 4, 4 });
            }
        }

        internal static Experiment Taguchi_L8_4_2_1_4 {
            get {
                return new Experiment(new int[,]{
                    {0,0,0,0,0},
                    {0,0,1,1,1},
                    {0,1,0,1,2},
                    {0,1,1,0,3},
                    {1,1,1,1,0},
                    {1,1,0,0,1},
                    {1,0,1,0,2},
                    {1,0,0,1,3}
                }, new int[] { 2, 2, 2, 2, 4 });
            }
        }

        internal static Experiment Taguchi_L16_12_2_1_4 {
            get {
                return new Experiment(new int[,]{
                    {0,0,0,0,0,0,0,0,0,0,0,0,0},
                    {0,0,0,0,1,1,1,1,1,1,1,1,0},
                    {1,1,1,1,0,0,0,0,1,1,1,1,0},
                    {1,1,1,1,1,1,1,1,0,0,0,0,0},
                    {0,0,1,1,0,0,1,1,0,0,1,1,1},
                    {0,0,1,1,1,1,0,0,1,1,0,0,1},
                    {1,1,0,0,0,0,1,1,1,1,0,0,1},
                    {1,1,0,0,1,1,0,0,0,0,1,1,1},
                    {0,1,0,1,0,1,0,1,0,1,0,1,2},
                    {0,1,0,1,1,0,1,0,1,0,1,0,2},
                    {1,0,1,0,0,1,0,1,1,0,1,0,2},
                    {1,0,1,0,1,0,1,0,0,1,0,1,2},
                    {0,1,1,0,0,1,1,0,0,1,1,0,3},
                    {0,1,1,0,1,0,0,1,1,0,0,1,3},
                    {1,0,0,1,0,1,1,0,1,0,0,1,3},
                    {1,0,0,1,1,0,0,1,0,1,1,0,3}
                }, new int[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 4 });
            }
        }

        internal static Experiment Taguchi_L16_9_2_2_4 {
            get {
                return new Experiment(new int[,]{
                    {0,0,0,0,0,0,0,0,0,0,0},
                    {0,0,0,1,1,1,1,1,1,0,1},
                    {1,1,1,0,0,0,1,1,1,0,2},
                    {1,1,1,1,1,1,0,0,0,0,3},
                    {0,1,1,0,1,1,0,1,1,1,0},
                    {0,1,1,1,0,0,1,0,0,1,1},
                    {1,0,0,0,1,1,1,0,0,1,2},
                    {1,0,0,1,0,0,0,1,1,1,3},
                    {1,0,1,1,0,1,1,0,1,2,0},
                    {1,0,1,0,1,0,0,1,0,2,1},
                    {0,1,0,1,0,1,0,1,0,2,1},
                    {0,1,0,0,1,0,1,0,1,2,3},
                    {1,1,0,1,1,0,1,1,0,3,0},
                    {1,1,0,0,0,1,0,0,1,3,1},
                    {0,0,1,1,1,0,0,0,1,3,2},
                    {0,0,1,0,0,1,1,1,0,3,3}
                }, new int[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4 });
            }
        }

        internal static Experiment Taguchi_L16_6_2_3_4 {
            get {
                return new Experiment(new int[,]{
                    {0,0,0,0,0,0,0,0,0},
                    {0,0,1,1,1,1,0,1,1},
                    {1,1,0,0,1,1,0,2,2},
                    {1,1,1,1,0,0,0,3,3},
                    {1,1,0,1,0,1,1,0,1},
                    {1,1,1,0,1,0,1,1,0},
                    {0,0,0,1,1,0,1,2,3},
                    {0,0,1,0,0,1,1,3,2},
                    {0,1,1,1,1,0,2,0,2},
                    {0,1,0,0,0,1,0,1,3},
                    {1,0,1,1,0,1,0,0,0},
                    {1,0,0,0,1,0,2,3,1},
                    {1,0,1,0,1,1,3,0,3},
                    {1,0,0,1,0,0,3,1,2},
                    {0,1,1,0,0,0,3,0,1},
                    {0,1,0,1,1,1,3,3,0}
                }, new int[] { 2, 2, 2, 2, 2, 2, 4, 4, 4 });
            }
        }

        internal static Experiment Taguchi_L16_3_2_4_4 {
            get {
                return new Experiment(new int[,]{
                    {0,0,0,0,0,0,0},
                    {0,1,1,0,1,1,1},
                    {1,0,1,0,2,2,2},
                    {1,1,0,0,3,3,3},
                    {1,1,0,1,0,1,0},
                    {1,0,1,1,1,0,1},
                    {0,1,1,1,2,3,3},
                    {0,0,0,1,3,2,2},
                    {0,1,1,2,0,2,3},
                    {0,0,0,2,1,3,2},
                    {1,1,0,2,2,0,1},
                    {1,0,1,2,3,1,0},
                    {1,0,1,3,0,3,1},
                    {1,1,0,3,1,2,0},
                    {0,0,0,3,2,1,3},
                    {0,1,1,3,3,0,2}
                }, new int[] { 2, 2, 2, 4, 4, 4, 4 });
            }
        }

        internal static Experiment Taguchi_L18_1_2_7_3 {
            get {
                return new Experiment(new int[,]{
                    {0,0,0,0,0,0,0,0},
                    {0,0,1,1,1,1,1,1},
                    {0,0,2,2,2,2,2,2},
                    {0,1,0,0,1,1,2,2},
                    {0,1,1,1,2,2,0,0},
                    {0,1,2,2,0,0,1,1},
                    {0,2,0,1,0,2,1,2},
                    {0,2,1,2,1,0,2,0},
                    {0,2,2,0,2,1,0,1},
                    {1,0,0,2,2,1,1,0},
                    {1,0,1,0,0,2,2,1},
                    {1,0,2,1,1,0,0,2},
                    {1,1,0,1,2,0,2,1},
                    {1,1,1,2,0,1,0,2},
                    {1,1,2,0,1,2,1,0},
                    {1,2,0,2,1,2,0,1},
                    {1,2,1,0,2,0,1,2},
                    {1,2,2,1,0,1,2,0}
                }, new int[] { 2, 3, 3, 3, 3, 3, 3, 3 });
            }
        }

        internal static Experiment Taguchi_L25_6_5 {
            get {
                return new Experiment(new int[,]{
                    {0,0,0,0,0,0},
                    {0,1,1,1,1,1},
                    {0,2,2,2,2,2},
                    {0,3,3,3,3,3},
                    {0,4,4,4,4,4},
                    {1,0,1,2,3,4},
                    {1,1,2,3,4,0},
                    {1,2,3,4,0,1},
                    {1,3,4,0,1,2},
                    {1,4,0,1,2,3},
                    {2,0,2,4,1,3},
                    {2,1,3,0,2,4},
                    {2,2,4,1,3,0},
                    {2,3,0,2,4,1},
                    {2,4,1,3,0,2},
                    {3,0,3,1,4,2},
                    {3,1,4,2,0,3},
                    {3,2,0,3,1,4},
                    {3,3,1,4,2,0},
                    {3,4,2,0,3,1},
                    {4,0,4,3,2,1},
                    {4,1,0,4,3,2},
                    {4,2,1,0,4,3},
                    {4,3,2,1,0,4},
                    {4,4,3,2,1,0}
                }, new int[] { 5, 5, 5, 5, 5, 5 });
            }
        }

        #endregion Taguchi Designs


        #region Orthogonal Arrays

        internal static Experiment Orthogonal_4_3_2_2 {
            get {
                return new Experiment(new int[,]{
                    {0,0,0},
                    {0,1,1},
                    {1,0,1},
                    {1,1,0}
                }, new int[] { 2, 2, 2 });
            }
        }

        internal static Experiment Orthogonal_8_5_2_2 {
            get {
                return new Experiment(new int[,]{
					{0,0,0,0,0},
					{1,0,0,1,1},
					{0,1,0,1,0},
					{0,0,1,0,1},
					{1,1,0,0,1},
					{1,0,1,1,0},
					{0,1,1,1,1},
					{1,1,1,0,0}
                }, new int[] { 2, 2, 2, 2, 2 });
            }
        }

        internal static Experiment Orthogonal_8_7_2_2 {
            get {
                return new Experiment(new int[,]{
					{0,0,0,0,0,0,0},
					{1,0,1,0,1,0,1},
					{0,1,1,0,0,1,1},
					{1,1,0,0,1,1,0},
					{0,0,0,1,1,1,1},
					{1,0,1,1,0,1,0},
					{0,1,1,1,1,0,0},
					{1,1,0,1,0,0,1}
                }, new int[] { 2, 2, 2, 2, 2, 2, 2 });
            }
        }

        internal static Experiment Orthogonal_12_11_2_2 {
            get {
                return new Experiment(new int[,]{
					{1,1,1,1,1,1,1,1,1,1,1},
					{0,1,0,1,1,1,0,0,0,1,0},
					{0,0,1,0,1,1,1,0,0,0,1},
					{1,0,0,1,0,1,1,1,0,0,0},
					{0,1,0,0,1,0,1,1,1,0,0},
					{0,0,1,0,0,1,0,1,1,1,0},
					{0,0,0,1,0,0,1,0,1,1,1},
					{1,0,0,0,1,0,0,1,0,1,1},
					{1,1,0,0,0,1,0,0,1,0,1},
					{1,1,1,0,0,0,1,0,0,1,0},
					{0,1,1,1,0,0,0,1,0,0,1},
					{1,0,1,1,1,0,0,0,1,0,0}
                }, new int[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 });
            }
        }

        internal static Experiment Orthogonal_16_15_2_2 {
            get {
                return new Experiment(new int[,]{
					{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
					{1,0,1,0,1,0,1,0,1,0,1,0,1,0,1},
					{0,1,1,0,0,1,1,0,0,1,1,0,0,1,1},
					{1,1,0,0,1,1,0,0,1,1,0,0,1,1,0},
					{0,0,0,1,1,1,1,0,0,0,0,1,1,1,1},
					{1,0,1,1,0,1,0,0,1,0,1,1,0,1,0},
					{0,1,1,1,1,0,0,0,0,1,1,1,1,0,0},
					{1,1,0,1,0,0,1,0,1,1,0,1,0,0,1},
					{0,0,0,0,0,0,0,1,1,1,1,1,1,1,1},
					{1,0,1,0,1,0,1,1,0,1,0,1,0,1,0},
					{0,1,1,0,0,1,1,1,1,0,0,1,1,0,0},
					{1,1,0,0,1,1,0,1,0,0,1,1,0,0,1},
					{0,0,0,1,1,1,1,1,1,1,1,0,0,0,0},
					{1,0,1,1,0,1,0,1,0,1,0,0,1,0,1},
					{0,1,1,1,1,0,0,1,1,0,0,0,0,1,1},
					{1,1,0,1,0,0,1,1,0,0,1,0,1,1,0}
                }, new int[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 });
            }
        }

        internal static Experiment Orthogonal_20_19_2_2 {
            get {
                return new Experiment(new int[,]{
					{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
					{1,0,1,1,0,0,0,0,1,0,1,0,1,1,1,1,0,0,1},
					{1,1,0,1,1,0,0,0,0,1,0,1,0,1,1,1,1,0,0},
					{0,1,1,0,1,1,0,0,0,0,1,0,1,0,1,1,1,1,0},
					{0,0,1,1,0,1,1,0,0,0,0,1,0,1,0,1,1,1,1},
					{1,0,0,1,1,0,1,1,0,0,0,0,1,0,1,0,1,1,1},
					{1,1,0,0,1,1,0,1,1,0,0,0,0,1,0,1,0,1,1},
					{1,1,1,0,0,1,1,0,1,1,0,0,0,0,1,0,1,0,1},
					{1,1,1,1,0,0,1,1,0,1,1,0,0,0,0,1,0,1,0},
					{0,1,1,1,1,0,0,1,1,0,1,1,0,0,0,0,1,0,1},
					{1,0,1,1,1,1,0,0,1,1,0,1,1,0,0,0,0,1,0},
					{0,1,0,1,1,1,1,0,0,1,1,0,1,1,0,0,0,0,1},
					{1,0,1,0,1,1,1,1,0,0,1,1,0,1,1,0,0,0,0},
					{0,1,0,1,0,1,1,1,1,0,0,1,1,0,1,1,0,0,0},
					{0,0,1,0,1,0,1,1,1,1,0,0,1,1,0,1,1,0,0},
					{0,0,0,1,0,1,0,1,1,1,1,0,0,1,1,0,1,1,0},
					{0,0,0,0,1,0,1,0,1,1,1,1,0,0,1,1,0,1,1},
					{1,0,0,0,0,1,0,1,0,1,1,1,1,0,0,1,1,0,1},
					{1,1,0,0,0,0,1,0,1,0,1,1,1,1,0,0,1,1,0},
					{0,1,1,0,0,0,0,1,0,1,0,1,1,1,1,0,0,1,1}
                }, new int[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 });
            }
        }

        internal static Experiment Orthogonal_8_4_2_3 {
            get {
                return new Experiment(new int[,]{
					{0,0,0,0},
					{0,0,1,1},
					{0,1,0,1},
					{0,1,1,0},
					{1,0,0,1},
					{1,0,1,0},
					{1,1,0,0},
					{1,1,1,1}
                }, new int[] { 2, 2, 2, 2 });
            }
        }

        internal static Experiment Orthogonal_16_8_2_3 {
            get {
                return new Experiment(new int[,]{
					{0,0,0,0,0,0,0,0},
					{0,1,0,1,0,1,0,1},
					{0,0,1,1,0,0,1,1},
					{0,1,1,0,0,1,1,0},
					{0,0,0,0,1,1,1,1},
					{0,1,0,1,1,0,1,0},
					{0,0,1,1,1,1,0,0},
					{0,1,1,0,1,0,0,1},
					{1,1,1,1,1,1,1,1},
					{1,0,1,0,1,0,1,0},
					{1,1,0,0,1,1,0,0},
					{1,0,0,1,1,0,0,1},
					{1,1,1,1,0,0,0,0},
					{1,0,1,0,0,1,0,1},
					{1,1,0,0,0,0,1,1},
					{1,0,0,1,0,1,1,0}
                }, new int[] { 2, 2, 2, 2, 2, 2, 2, 2 });
            }
        }

        internal static Experiment Orthogonal_24_12_2_3 {
            get {
                return new Experiment(new int[,]{
					{0,1,1,1,1,1,1,1,1,1,1,1},
					{0,0,1,0,1,1,1,0,0,0,1,0},
					{0,0,0,1,0,1,1,1,0,0,0,1},
					{0,1,0,0,1,0,1,1,1,0,0,0},
					{0,0,1,0,0,1,0,1,1,1,0,0},
					{0,0,0,1,0,0,1,0,1,1,1,0},
					{0,0,0,0,1,0,0,1,0,1,1,1},
					{0,1,0,0,0,1,0,0,1,0,1,1},
					{0,1,1,0,0,0,1,0,0,1,0,1},
					{0,1,1,1,0,0,0,1,0,0,1,0},
					{0,0,1,1,1,0,0,0,1,0,0,1},
					{0,1,0,1,1,1,0,0,0,1,0,0},
					{1,0,0,0,0,0,0,0,0,0,0,0},
					{1,1,0,1,0,0,0,1,1,1,0,1},
					{1,1,1,0,1,0,0,0,1,1,1,0},
					{1,0,1,1,0,1,0,0,0,1,1,1},
					{1,1,0,1,1,0,1,0,0,0,1,1},
					{1,1,1,0,1,1,0,1,0,0,0,1},
					{1,1,1,1,0,1,1,0,1,0,0,0},
					{1,0,1,1,1,0,1,1,0,1,0,0},
					{1,0,0,1,1,1,0,1,1,0,1,0},
					{1,0,0,0,1,1,1,0,1,1,0,1},
					{1,1,0,0,0,1,1,1,0,1,1,0},
					{1,0,1,0,0,0,1,1,1,0,1,1}
                }, new int[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 });
            }
        }

        internal static Experiment Orthogonal_32_16_2_3 {
            get {
                return new Experiment(new int[,]{
					{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
					{0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1},
					{0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1},
					{0,1,1,0,0,1,1,0,0,1,1,0,0,1,1,0},
					{0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1},
					{0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0},
					{0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0},
					{0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1},
					{0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1},
					{0,1,0,1,0,1,0,1,1,0,1,0,1,0,1,0},
					{0,0,1,1,0,0,1,1,1,1,0,0,1,1,0,0},
					{0,1,1,0,0,1,1,0,1,0,0,1,1,0,0,1},
					{0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0},
					{0,1,0,1,1,0,1,0,1,0,1,0,0,1,0,1},
					{0,0,1,1,1,1,0,0,1,1,0,0,0,0,1,1},
					{0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0},
					{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
					{1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0},
					{1,1,0,0,1,1,0,0,1,1,0,0,1,1,0,0},
					{1,0,0,1,1,0,0,1,1,0,0,1,1,0,0,1},
					{1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0},
					{1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1},
					{1,1,0,0,0,0,1,1,1,1,0,0,0,0,1,1},
					{1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0},
					{1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0},
					{1,0,1,0,1,0,1,0,0,1,0,1,0,1,0,1},
					{1,1,0,0,1,1,0,0,0,0,1,1,0,0,1,1},
					{1,0,0,1,1,0,0,1,0,1,1,0,0,1,1,0},
					{1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1},
					{1,0,1,0,0,1,0,1,0,1,0,1,1,0,1,0},
					{1,1,0,0,0,0,1,1,0,0,1,1,1,1,0,0},
					{1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1}
                }, new int[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 });
            }
        }

        internal static Experiment Orthogonal_40_20_2_3 {
            get {
                return new Experiment(new int[,]{
					{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
					{0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1},
					{0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1},
					{0,1,1,1,1,1,0,0,0,0,1,0,0,0,0,0,1,1,1,1},
					{0,0,1,1,1,0,0,0,1,1,0,0,0,1,1,1,0,0,1,1},
					{0,1,0,1,1,0,0,0,1,1,0,1,1,0,0,1,1,1,0,0},
					{0,1,1,0,1,0,1,1,0,0,0,0,0,1,1,1,1,1,0,0},
					{0,1,1,1,0,0,1,1,0,0,0,1,1,0,0,1,0,0,1,1},
					{1,1,0,0,1,0,0,1,0,1,0,0,1,0,1,0,0,1,1,1},
					{1,1,0,0,1,0,1,0,1,0,0,1,0,1,0,0,1,0,1,1},
					{1,0,1,1,0,0,0,1,0,1,0,1,0,1,0,0,1,1,0,1},
					{1,0,1,1,0,0,1,0,1,0,0,0,1,0,1,0,1,1,1,0},
					{1,1,0,1,0,0,0,1,1,0,1,0,0,0,1,1,1,0,0,1},
					{1,1,0,1,0,0,1,0,0,1,1,0,0,1,0,1,0,1,1,0},
					{1,0,1,0,1,0,1,0,0,1,1,0,1,0,0,1,1,0,0,1},
					{1,0,1,0,1,0,0,1,1,0,1,1,0,0,0,1,0,1,1,0},
					{1,1,1,0,0,1,0,0,0,1,0,1,0,0,1,1,1,0,1,0},
					{1,1,1,0,0,1,0,0,1,0,0,0,1,1,0,1,0,1,0,1},
					{1,0,0,1,1,1,0,1,0,0,0,0,1,1,0,1,1,0,1,0},
					{1,0,0,1,1,1,1,0,0,0,0,1,0,0,1,1,0,1,0,1},
					{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
					{1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0},
					{1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0},
					{1,0,0,0,0,0,1,1,1,1,0,1,1,1,1,1,0,0,0,0},
					{1,1,0,0,0,1,1,1,0,0,1,1,1,0,0,0,1,1,0,0},
					{1,0,1,0,0,1,1,1,0,0,1,0,0,1,1,0,0,0,1,1},
					{1,0,0,1,0,1,0,0,1,1,1,1,1,0,0,0,0,0,1,1},
					{1,0,0,0,1,1,0,0,1,1,1,0,0,1,1,0,1,1,0,0},
					{0,0,1,1,0,1,1,0,1,0,1,1,0,1,0,1,1,0,0,0},
					{0,0,1,1,0,1,0,1,0,1,1,0,1,0,1,1,0,1,0,0},
					{0,1,0,0,1,1,1,0,1,0,1,0,1,0,1,1,0,0,1,0},
					{0,1,0,0,1,1,0,1,0,1,1,1,0,1,0,1,0,0,0,1},
					{0,0,1,0,1,1,1,0,0,1,0,1,1,1,0,0,0,1,1,0},
					{0,0,1,0,1,1,0,1,1,0,0,1,1,0,1,0,1,0,0,1},
					{0,1,0,1,0,1,0,1,1,0,0,1,0,1,1,0,0,1,1,0},
					{0,1,0,1,0,1,1,0,0,1,0,0,1,1,1,0,1,0,0,1},
					{0,0,0,1,1,0,1,1,1,0,1,0,1,1,0,0,0,1,0,1},
					{0,0,0,1,1,0,1,1,0,1,1,1,0,0,1,0,1,0,1,0},
					{0,1,1,0,0,0,1,0,1,1,1,1,0,0,1,0,0,1,0,1},
					{0,1,1,0,0,0,0,1,1,1,1,0,1,1,0,0,1,0,1,0}
                }, new int[] { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 });
            }
        }

        internal static Experiment Orthogonal_9_4_3_2 {
            get {
                return new Experiment(new int[,]{
					{0,0,0,0},
					{0,1,1,2},
					{0,2,2,1},
					{1,0,1,1},
					{1,1,2,0},
					{1,2,0,2},
					{2,0,2,2},
					{2,1,0,1},
					{2,2,1,0}
                }, new int[] { 3, 3, 3, 3 });
            }
        }

        internal static Experiment Orthogonal_18_7_3_2 {
            get {
                return new Experiment(new int[,]{
					{0,0,0,0,0,0,0},
					{1,1,1,1,1,1,0},
					{2,2,2,2,2,2,0},
					{0,0,1,2,1,2,0},
					{1,1,2,0,2,0,0},
					{2,2,0,1,0,1,0},
					{0,1,0,2,2,1,1},
					{1,2,1,0,0,2,1},
					{2,0,2,1,1,0,1},
					{0,2,2,0,1,1,1},
					{1,0,0,1,2,2,1},
					{2,1,1,2,0,0,1},
					{0,1,2,1,0,2,2},
					{1,2,0,2,1,0,2},
					{2,0,1,0,2,1,2},
					{0,2,1,1,2,0,2},
					{1,0,2,2,0,1,2},
					{2,1,0,0,1,2,2}
                }, new int[] { 3, 3, 3, 3, 3, 3, 3 });
            }
        }

        internal static Experiment Orthogonal_27_13_3_2 {
            get {
                return new Experiment(new int[,]{
					{0,0,0,0,0,0,0,0,0,0,0,0,0},
					{1,0,1,1,1,2,2,0,1,2,1,0,0},
					{2,0,2,2,2,1,1,0,2,1,2,0,0},
					{0,1,0,1,1,1,2,2,0,1,2,1,0},
					{1,1,1,2,2,0,1,2,1,0,0,1,0},
					{2,1,2,0,0,2,0,2,2,2,1,1,0},
					{0,2,0,2,2,2,1,1,0,2,1,2,0},
					{1,2,1,0,0,1,0,1,1,1,2,2,0},
					{2,2,2,1,1,0,2,1,2,0,0,2,0},
					{0,0,1,0,1,1,1,2,2,0,1,2,1},
					{1,0,2,1,2,0,0,2,0,2,2,2,1},
					{2,0,0,2,0,2,2,2,1,1,0,2,1},
					{0,1,1,1,2,2,0,1,2,1,0,0,1},
					{1,1,2,2,0,1,2,1,0,0,1,0,1},
					{2,1,0,0,1,0,1,1,1,2,2,0,1},
					{0,2,1,2,0,0,2,0,2,2,2,1,1},
					{1,2,2,0,1,2,1,0,0,1,0,1,1},
					{2,2,0,1,2,1,0,0,1,0,1,1,1},
					{0,0,2,0,2,2,2,1,1,0,2,1,2},
					{1,0,0,1,0,1,1,1,2,2,0,1,2},
					{2,0,1,2,1,0,0,1,0,1,1,1,2},
					{0,1,2,1,0,0,1,0,1,1,1,2,2},
					{1,1,0,2,1,2,0,0,2,0,2,2,2},
					{2,1,1,0,2,1,2,0,0,2,0,2,2},
					{0,2,2,2,1,1,0,2,1,2,0,0,2},
					{1,2,0,0,2,0,2,2,2,1,1,0,2},
					{2,2,1,1,0,2,1,2,0,0,2,0,2}
                }, new int[] { 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 });
            }
        }

        internal static Experiment Orthogonal_16_5_4_2 {
            get {
                return new Experiment(new int[,]{
					{0,0,0,0,0},
					{0,1,1,1,1},
					{0,2,2,2,2},
					{0,3,3,3,3},
					{1,0,1,2,3},
					{1,1,0,3,2},
					{1,2,3,0,1},
					{1,3,2,1,0},
					{2,0,2,3,1},
					{2,1,3,2,0},
					{2,2,0,1,3},
					{2,3,1,0,2},
					{3,0,3,1,2},
					{3,1,2,0,3},
					{3,2,1,3,0},
					{3,3,0,2,1}
                }, new int[] { 4, 4, 4, 4, 4 });
            }
        }

        internal static Experiment Orthogonal_32_9_4_2 {
            get {
                return new Experiment(new int[,]{
					{0,0,3,3,3,3,1,2,0},
					{0,1,2,0,2,1,3,1,3},
					{0,2,1,2,0,0,2,3,2},
					{0,3,0,1,1,2,0,0,1},
					{1,0,2,2,1,3,3,3,1},
					{1,1,3,1,0,1,1,0,2},
					{1,2,0,3,2,0,0,2,3},
					{1,3,1,0,3,2,2,1,0},
					{2,0,1,3,0,2,3,0,3},
					{2,1,0,0,1,0,1,3,0},
					{2,2,3,2,3,1,0,1,1},
					{2,3,2,1,2,3,2,2,2},
					{3,0,0,2,2,2,1,1,2},
					{3,1,1,1,3,0,3,2,1},
					{3,2,2,3,1,1,2,0,0},
					{3,3,3,0,0,3,0,3,3},
					{0,0,3,1,1,0,2,1,3},
					{0,1,2,2,0,2,0,2,0},
					{0,2,1,0,2,3,1,0,1},
					{0,3,0,3,3,1,3,3,2},
					{1,0,2,0,3,0,0,0,2},
					{1,1,3,3,2,2,2,3,1},
					{1,2,0,1,0,3,3,1,0},
					{1,3,1,2,1,1,1,2,3},
					{2,0,1,1,2,1,0,3,0},
					{2,1,0,2,3,3,2,0,3},
					{2,2,3,0,1,2,3,2,2},
					{2,3,2,3,0,0,1,1,1},
					{3,0,0,0,0,1,2,2,1},
					{3,1,1,3,1,3,0,1,2},
					{3,2,2,1,3,2,1,3,3},
					{3,3,3,2,2,0,3,0,0}
                }, new int[] { 4, 4, 4, 4, 4, 4, 4, 4, 4 });
            }
        }

        internal static Experiment Orthogonal_25_6_5_2 {
            get {
                return new Experiment(new int[,]{
					{0,0,0,0,0,0},
					{0,1,1,2,3,4},
					{0,2,2,3,4,1},
					{0,3,3,4,1,2},
					{0,4,4,1,2,3},
					{1,0,1,1,1,1},
					{1,1,2,4,0,3},
					{1,2,4,0,3,2},
					{1,3,0,3,2,4},
					{1,4,3,2,4,0},
					{2,0,2,2,2,2},
					{2,1,4,3,1,0},
					{2,2,3,1,0,4},
					{2,3,1,0,4,3},
					{2,4,0,4,3,1},
					{3,0,3,3,3,3},
					{3,1,0,1,4,2},
					{3,2,1,4,2,0},
					{3,3,4,2,0,1},
					{3,4,2,0,1,4},
					{4,0,4,4,4,4},
					{4,1,3,0,2,1},
					{4,2,0,2,1,3},
					{4,3,2,1,3,0},
					{4,4,1,3,0,2}
                }, new int[] { 5, 5, 5, 5, 5, 5 });
            }
        }

        #endregion Orthogonal Arrays

    }

}
